// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store
const api = {
  /**
	 * 获取按钮权限
	 * @param {*} params menuId
	 */
  reqButtonPermission(params) {
    return Service.get(`/${ServiceName}/api/external/sysmenubtn/listresourcebtnbyid?menuId=${params}`, { timeout: 30000 })
  },
  /**
     * 获取国际数据
     * @param {Object} params 检索条件的obj
     */
  reqGetInternational(params) {
    return Service.get(`/${ServiceName}/api/external/mtport/queryall?isDomestic=N`, { params })
  },
  /**
     * 保存国际/国内数据
     * @param {Object} params 保存的form
     */
  reqSaveInternational(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/mtport/insert`,
      params
    )
  },
  /**
     * 编辑国际数据
     * @param {Object} params 编辑的form
     */
  reqEditInternational(params) {
    return Service.put(
      `/${ServiceName}/api/external/mtport/update?isDomestic=N`,
      params
    )
  },
  /**
     * 获取国内数据
     * @param {Object} params 检索条件的obj
     */
  reqGetInner(params) {
    return Service.get(
      `/${ServiceName}/api/external/mtport/queryall?isDomestic=Y`,
      { params }
    )
  },
  /**
     * 编辑国内数据
     * @param {Object} params 编辑的form
     */
  reqEditInner(params) {
    return Service.put(
      `/${ServiceName}/api/external/mtport/update?isDomestic=Y`,
      params
    )
  },
  /**
     * 获取国籍
     */
  reqGetNationData() {
    return Service.get(
      `/${ServiceName}/api/external/publics/listalldict?dicttype=NATIONALITY`
    )
  },
  /**
     * 获取船舶类型
     */
  getShipTypeData() {
    return Service.get(
      `/${ServiceName}/api/external/public/listdict?dicttype=SHIPTYPE`
    )
  },
  /**
     * 获取省份
     */
  reqGetProvinceData() {
    return Service.get(
      `/${ServiceName}/api/external/publics/getprovince`
    )
  },
  /**
     * 获取区域
     */
  getRegionData() {
    return Service.get(
      `/${ServiceName}/api/external/public/listdict?dicttype=REGION`
    )
  },
  /**
     * 获取城市
     * @param {*} params 根据省份
     */
  reqGetCityData(params) {
    return Service.get(
      `/${ServiceName}/api/external/publics/getcitybyprovince?dm=${params}`
    )
  },
  /**
   * 删除数据
   * @param {*} id 数据id
   */
  reqDelete(id) {
    return Service.delete(
      `/${ServiceName}/api/external/mtport/deletebyid?id=${id}`
    )
  }
}
export default api
